/**
 * 
 */
package sg.edu.nus.iss.team8s.vmcs.payment;

/**
 * @author Wang Shi Jie
 *
 */
public class PaymentModeFactory {
	public static final String COIN_PAYMENT = "coin";
	public static final String CASHCARD_PAYMENT = "cashcard";
	
	public static PaymentModeFactory factory = null;
	
	private PaymentModeFactory(){
		System.out.println("<PaymentModeFactory> - constructor() : create new PaymentModeFactory");
	}
	
	public synchronized static PaymentModeFactory getInstance(){
		if(factory == null){
			factory = new PaymentModeFactory();
		}
		
		System.out.println("<PaymentModeFactory> - getInstance() : get PaymentModeFactory instance");
		return factory;
	}
	
	public PaymentMode createPaymentMode(String paymentMode){
		if(PaymentModeFactory.COIN_PAYMENT.equals(paymentMode)){
			return new CoinPayment();
		}
		
		if(PaymentModeFactory.CASHCARD_PAYMENT.equals(paymentMode)){
			return new CashcardPayment(new CashcardReceiver());
		}
		
		return null;
	}
}
